import 'package:flutter/material.dart';
import 'package:wheel_of_fortune/utils/utils.dart';

import 'customer_button.dart';
import 'redeem_spin.dart';

class NoSpins extends StatefulWidget {
  ///
  final int candyExchangeAmount;
  final rotaryTableId;
  const NoSpins(
      {this.candyExchangeAmount = 10, this.rotaryTableId = '', Key key})
      : super(key: key);

  @override
  _NoCandyState createState() => _NoCandyState();
}

class _NoCandyState extends State<NoSpins> {

  int type;
  select(i){
    setState(() {
      type = i;
    });
  }

  @override
  Widget build(BuildContext context) {
    return type != null? RedeemSpin(type:type)
    :Container(
      alignment: Alignment.center,
      color: Colors.white,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            color: mainColor,
            child: Image.asset(
              'assets/images/messages_alerts.png',
              fit: BoxFit.fill,
            ),
          ),
          Container(
            padding: EdgeInsets.only(top: 30, bottom: 60),
            alignment: Alignment.center,
            child: Text(
              'Insufficient Spins!',
              textAlign: TextAlign.center,
              style: TextStyle(
                color: mainColor,
                fontSize: 26,
                fontFamily: 'Avenir Next LT Pro',
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              BgButton(
                title: 'Spin using Candy',
                width: 200.0,
                color: deepYellowColor,
                onTap: ()=> select(0),
              ),
              SizedBox(
                height: 20,
              ),
              BgButton(
                title: 'Purchase Spin',
                width: 200.0,
                color: deepYellowColor,
                onTap: ()=> select(1),
              ),
              SizedBox(
                height: 20,
              ),
              InkWell(
                onTap: () => Navigator.of(context).pop(false),
                child: Text(
                  'Cancel',
                  style: TextStyle(
                    color: greyDBColor,
                    fontSize: 16,
                    fontFamily: 'Avenir Next LT Pro',
                  ),
                ),
              ),
            ],
          ),
          SizedBox(
            height: 30,
          ),
        ],
      ),
    );
  }
}
